package com.common.sp;

import com.curry.android.util.StringUtil;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Administrator on 2016/7/25.
 */
public class OtherSp {

    /** 获取红包ID */
    public static String getRedEnvelopeID() {
        return SharedPreferUtil.getInstance().getString("redEnvelopeID", "");
    }

    public static void setRedEnvelopeID(String redEnvelopeID) {
        SharedPreferUtil.getInstance().putString("redEnvelopeID", redEnvelopeID);
    }


    public static void setLastLoginID(String lastLoginID) {
        if (StringUtil.isBlank(lastLoginID)) {
            return;
        }
        SharedPreferUtil.getInstance().putString(SharedPreferUtil.APP_INFO, "lastLoginID", lastLoginID);
    }

    /** 减少HTTP请求认证状态次数用，获取最近一次用户ID，用于判断是否已经更换了用户 */
    public static String getLastLoginID() {
        return SharedPreferUtil.getInstance().getString(SharedPreferUtil.APP_INFO,"lastLoginID", "defaultLoginID");
    }

    public static void setLastCommID(String lastCommID) {
        if (StringUtil.isBlank(lastCommID)) {
            return;
        }
        SharedPreferUtil.getInstance().putString(SharedPreferUtil.APP_INFO, "lastCommID", lastCommID);
    }


    /** 获取昨天选择过的小区id集合 */
    public static Set<String> getYesterdayCommIDSet() {
        Set<String> set=new HashSet<>();
        return SharedPreferUtil.getInstance().getStringSet(SharedPreferUtil.PRECOMMID_INFO,"yesterdayCommIDs", set);
    }

    public static void putYesterdayCommIDSet(Set<String> commIDs) {
        SharedPreferUtil.getInstance().putStringSet(SharedPreferUtil.PRECOMMID_INFO, "yesterdayCommIDs", commIDs);
    }

    /** 获取今天选择过的小区id集合 */
    public static Set<String> getTodayCommIDSet() {
        Set<String> set=new HashSet<>();
        return SharedPreferUtil.getInstance().getStringSet(SharedPreferUtil.TODAY_COMMID_INFO,"todayCommIDs", set);
    }

    public static void putTodayCommIDSet(Set<String> commIDs) {
        SharedPreferUtil.getInstance().putStringSet(SharedPreferUtil.TODAY_COMMID_INFO, "todayCommIDs", commIDs);
    }

    /** 获取小区ID对应的广告图片信息 */
    public static String getAdImgInfo(String key) {

        return SharedPreferUtil.getInstance().getString(SharedPreferUtil.APP_INFO,key, "");
    }

    public static void putAdImgInfo(String key,String adImgInfo) {
        SharedPreferUtil.getInstance().putString(SharedPreferUtil.APP_INFO, key, adImgInfo);
    }

    /** 获取小区ID对应的广告图片titile */
    public static String getAdImgTitile() {

        return SharedPreferUtil.getInstance().getString(SharedPreferUtil.APP_INFO,"AdImgTitle", "");
    }

    public static void putAdImgTitle(String adImgInfo) {
        SharedPreferUtil.getInstance().putString(SharedPreferUtil.APP_INFO, "AdImgTitle", adImgInfo);
    }

    /** 判断是否成功下载该小区广告图片 */
    public static boolean getIsSuccessLoadImg(String key) {
        String newKey="bkey"+key;
        return SharedPreferUtil.getInstance().getBoolean(SharedPreferUtil.APP_INFO,newKey, false);
    }

    public static void putIsSuccessLoadImg(String key,boolean var) {
        String newKey="bkey"+key;
        SharedPreferUtil.getInstance().putBoolean(SharedPreferUtil.APP_INFO, newKey, var);
    }



    /** 减少HTTP请求认证状态次数用，获取最近一次的小区，判断是否切换了小区 */
    public static String getLastCommID() {
        return SharedPreferUtil.getInstance().getString(SharedPreferUtil.APP_INFO,"lastCommID", "defaultCommID");
    }
}
